package com.itheima.homework1;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Course {
    public static void main(String[] args) {
        HashMap<String,String> hm = new HashMap<>();
        hm.put("Tom","java");
        hm.put("Kevin","python");
        hm.put("Lily","c++");
        hm.put("Lucy","PHP");
        //第一种
        Set<String> keySet = hm.keySet();
        for (String key : keySet) {
            String value = hm.get(key);
            System.out.println(key+"---"+value);
        }
        System.out.println("----------------------------");
        //第二种方法
        Set<Map.Entry<String, String>> entries = hm.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"---"+value);
        }
        System.out.println("----------------------------");
        //第三种
        hm.forEach((k,v)-> System.out.println(k+"---"+v));

    }
}
